Imports System
Imports System.Xml.Serialization

Namespace Aricie.DNN.Modules.LuceneSearch.SiteMap
    <XmlType(TypeName:="url")> _
    Public Class Url
        ' Methods
        Public Sub New()
        End Sub

        Public Sub New(ByVal pageUrl As Uri, ByVal lastModified As DateTime, ByVal changeFrequency As ChangeFrequency, ByVal priority As Decimal)
            Me._PageUrl = pageUrl
            Me._LastModified = lastModified
            Me._ChangeFrequency = changeFrequency
            Me._Priority = priority
        End Sub


        ' Properties
        <XmlElement(DataType:="anyURI", ElementName:="loc")> _
Public Property Location() As String
            Get
                Return Me._PageUrl.ToString
            End Get
            Set(ByVal value As String)
                Me._PageUrl = New Uri(value)
            End Set
        End Property

        <XmlElement(ElementName:="lastmod", DataType:="date")> _
        Public Property LastModified() As DateTime
            Get
                Return Me._LastModified
            End Get
            Set(ByVal value As DateTime)
                Me._LastModified = value
            End Set
        End Property

        <XmlElement(ElementName:="changefreq")> _
        Public Property ChangeFrequency() As ChangeFrequency
            Get
                Return Me._ChangeFrequency
            End Get
            Set(ByVal value As ChangeFrequency)
                Me._ChangeFrequency = value
            End Set
        End Property

        <XmlElement(ElementName:="priority")> _
        Public Property Priority() As Decimal
            Get
                Return Me._Priority
            End Get
            Set(ByVal value As Decimal)
                If ((value < 0.0) OrElse (value > 1.0)) Then
                    Throw New ArgumentOutOfRangeException("value", "Priority must be in range from 0.0 to 1.0!")
                End If
                Me._Priority = value
            End Set
        End Property


        ' Fields
        Private _PageUrl As Uri
        Private _LastModified As DateTime
        Private _ChangeFrequency As ChangeFrequency
        Private _Priority As Decimal
    End Class
End Namespace
